package com.emokili.ewa.portal.controller;

import com.emokili.ewa.common.utils.R;
import com.emokili.ewa.core.frame.service.FramePlayListService;
import com.emokili.ewa.core.frame.service.PlayListService;
import com.emokili.ewa.core.frame.service.PlayListSettingService;
import com.emokili.ewa.core.frame.vo.PlayListActiveVo;
import com.emokili.ewa.core.frame.vo.PlayListAddVo;
import com.emokili.ewa.core.frame.vo.PlayListSettingVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yuepanpan
 */
@RestController
@RequestMapping("/v1/playlists")
public class PlayListController {

    @Autowired
    private PlayListService playListService;
    @Autowired
    private PlayListSettingService playListSettingService;
    @Autowired
    private FramePlayListService framePlayListService;

    @GetMapping
    @ResponseBody
    public R list(){

        return null;
    }

    @RequestMapping("/update")
    @ResponseBody
    public R update(@RequestBody PlayListActiveVo playListActiveVo){
        playListService.changeActiveStatus(playListActiveVo);
        return R.ok();
    }

    /**
     * 相册设置
     * @param playListSettingVo
     * @return
     */
    @PostMapping("/settings")
    @ResponseBody
    public R settings(@RequestBody PlayListSettingVo playListSettingVo){
        playListSettingService.update(playListSettingVo);
        return R.ok();
    }

    @DeleteMapping("/{id}")
    public R delete(@PathVariable("id") Long id){
        playListService.deletePlayList(id);
        return R.ok();
    }

    @PostMapping("/add")
    @ResponseBody
    public R add(@RequestBody PlayListAddVo playListAddVo){
        playListService.createPlayList(playListAddVo);
        return R.ok();
    }
}
